<template>
	<view class="serviceIntroduct">
		<view class="service_con">
			<view class="serviceIntroduct_top">
				{{currentItem.title}}
			</view>
			<view class="serviceIntroduct_con">
				<view v-for="(item,index) in serviceData" :key="index" class="view_con">
					<view class="view_title">{{item.title}}</view>
					<view style="text-indent: 60rpx;" v-if="item.title1">
						{{item.title1}}
					</view>
					<view v-for="(child,id) in item.children" :key="id" style="line-height: 50rpx;">
						<text class="circular"></text>
						<text>{{child.title}}</text>
					</view>
					<view style="text-indent: 60rpx;" v-if="item.title2">
						{{item.title2}}
					</view>
				</view>
				<view class="view_con">
					<view class="view_title">服务有效期</view>
					<view style="line-height: 50rpx;">
						<text class="circular"></text>
						<text>服务次数：剩余<text>{{ numbers }}</text>次</text>
					</view>
					<view style="line-height: 50rpx;">
						<text class="circular"></text>
						<text>有效期：<text>{{ youxiaoqi }}</text> 起生效可用</text>
					</view>
				</view>
				<view class="view_con">
					<view class="view_title">服务共享人</view>
					<view style="line-height: 50rpx;">
						<text>{{ username }}</text>
						<text v-if="numbers>0" style="float: right;margin-right: 20rpx;">可申请预约</text>
						<text v-else style="float: right;margin-right: 20rpx;">不可申请预约</text>
					</view>
				</view>
			</view>
		</view>
		<view style="display: flex;align-items: center;">
			<text style="display: inline-block;width: 20%;text-align: center;margin-bottom: 10px;" @click.stop="Btnappointment">
				<image src="@/static/images/index/2.png" mode="" style="width: 60rpx;height: 60rpx;"></image>
				<view style="text-align: center;line-height: 0rpx;">预约记录</view>
			</text>
			<button v-if="numbers!=0" style="margin: 20rpx;width: 74%;display: inline-block;" class="plainlk1" @click.stop="Applyappointment">申请预约</button>
			<button v-else style="margin: 20rpx;width: 74%;display: inline-block;" class="plainlk1">不可申请</button>
		</view>
	</view>
</template>

<script>
	import {
		document_type,
		Beneficiaries,
		EditActivationCodes,
		provincelist,
		citylist,
		hospitalList,
		hospitalList2,
		addAppointment,
		updateAppointment,
		addRecord,
		updateRecord,
		RecordList
	} from "@/api/system/user"
	export default {
		data() {
			return {
				currentItem:{},
				numbers:0,
				youxiaoqi:'',
				username:"",
				serviceData: [
					{
						title: '服务内容',
						title1: '',
						children: [
							{
								title: '协助安排公立医院门诊就医；'
							},
							{
								title: '支持指定医院、科室（急诊科、生殖科、分娩科、美容科、保健科、计划生育科、ICU、干部病房、特殊科室及部分医院个别科室除外）；'
							},
							{
								title: '副主任及以上职称医师接诊。'
							}
						]
					},
					{
						title: '服务时效',
						title1: '',
						children: [
							{
								title: '提交申请后1个工作日内，服务专员会联系您确认需求；'
							},
							{
								title: '提交申请后，我们将在1-7个工作日内为您安排到院就诊，个别科室需根据科室安排确定时效；'
							},
							{
								title: '期间随时可能预约成功，预约成功后不可取消，请做好及时就医准备并保证手机畅通。'
							}
						]
					},
					{
						title: '服务支持',
						title1: '为保障顺利协调号源，需要您进行以下工作部分内容的支持：',
						children: [
							{
								title: '添加订单服务专员企业微信好友'
							},
							{
								title: '提供身份证、医院就诊卡、医保卡信息'
							},
							{
								title: '相关APP、小程序账户信息'
							},
							{
								title: '自行支付挂号费'
							}
						]
					},
					{
						title: '注意事项',
						title1: '在您与订单服务专员确认启动服务后，您的权益会被扣除。如因主观原因取消或未按时就诊，权益不再退还。如遇以下情况，导致服务无法按时完成，您可要求返还权益：',
						title2: '如遇科室资源紧张或上述状况时，您也可更换同级别医院对应科室使用服务。',
						children: [
							{
								title: '专家临时停诊'
							},
							{
								title: '政策法规变化影响门诊协调服务'
							},
							{
								title: '院方其他影响门诊协调服务的调整'
							}
						]
					},
					// {
					// 	title: '服务有效期',
					// 	title1: '',
					// 	children: [
					// 		{
					// 			title: '服务次数',
					// 			value:0,
					// 		},
					// 		{
					// 			title: '有效期',
					// 			value:''
					// 		}
					// 	]
					// }
				]
			}
		},
		onLoad: function(option) {
		  this.currentItem = JSON.parse(option.currentItem)
		  console.log(this.currentItem,'this.currentItem')
		  
		  this.youxiaoqi = this.currentItem.youxiaoqi
		  this.username = this.currentItem.username
		  this.getNumber()
		},
		methods: {
			Btnappointment(){
				uni.navigateTo({
					url: `/pages/code/yuyuejilu/yuyuejilu?disabled=true&currentItem=${JSON.stringify(this.currentItem)}`
				});
			},
			Applyappointment(){
				// ?currentItem=${JSON.stringify(currentItem)}
					uni.navigateTo({
						url: `/pages/code/Applyappointment?disabled=false&currentItem=${JSON.stringify(this.currentItem)}`
					});	
			},
		   getNumber(){
				RecordList(this.currentItem.activationCode,this.currentItem.exclusiveRightsID).then(red=>{
					if(red?.rows.length == 0){
						this.numbers = this.currentItem.Number
					} else {
						// 拿到当前数据进行number - 1
						this.numbers = red.rows[0].usageCount
					}
				})
			}
		}
	}
</script>

<style>
	.service_con{
		height: 92vh;
		overflow-y: auto;
	}
	.plainlk1 {
		border-color: transparent;
		background: #2786f2;
		color: rgb(255, 255, 255);
	}
	.view_con{
		background: #fff;
		padding: 20rpx;
		border-radius: 10rpx;
		margin-bottom: 20rpx;
	}
	.serviceIntroduct_top{
		min-height: 400rpx;
		margin-bottom: 20rpx;
		background: url('@/static/images/index/1.png') 0% 0% / 100% no-repeat;
		font-size: 60rpx;
		padding: 30rpx;
		line-height: 300rpx;
		color: #fff;
		font-weight: bold;
	}
	.serviceIntroduct_con{
		margin-top: -120rpx !important;
		margin: 20rpx;
	}
	.circular {
		display: inline-block;
		width: 12rpx;
		height: 12rpx;
		border-radius: 50%;
		background: #000;
		margin-right: 20rpx;
	}
	.view_title{
		text-align: center;
		font-size: 40rpx;
		padding: 30rpx;
		color: #2786f2;
		font-weight: bold;
	}
</style>